<template>
  <div style="width:100%;height:100%">
    <div class="maintenance-content-handle">
      <!-- <el-button type="primary"
                 @click="openDialog">新增</el-button> -->
    </div>
    <el-divider border-style="dashed" />
    <el-table :data="prizesLevelsListData"
              border
              stripe
              style="width:100%;height:100%;">
      <el-table-column fixed
                       prop="id"
                       label="序号"></el-table-column>
      <el-table-column prop="prizeName"
                       label="名称"></el-table-column>

      <el-table-column prop="levelName"
                       label="等级"></el-table-column>
      <el-table-column prop="phValue"
                       label="PH值"></el-table-column>
      <el-table-column prop="dataIndex"
                       label="随机排序"></el-table-column>
      <el-table-column prop="state"
                       label="状态">
        <template #default="scope">
          <el-tag v-if="scope.row.state === 0"
                  type="success">未开</el-tag>
          <el-tag v-else
                  type="danger">已开</el-tag>
        </template>
      </el-table-column>
      <!-- <el-table-column label="操作">
        <template #default="scope">
          <el-button
                     type="primary"
                     @click="editItem(scope.row)">编辑</el-button>
          <el-button
                     type="danger"
                     @click="deleteItem(scope.row)">删除</el-button>
        </template>
      </el-table-column> -->
    </el-table>
  </div>
</template>

<script lang='ts' setup>
import {
  ref,
  reactive,
  computed,
  watchEffect,
  watch,
  onBeforeMount,
  onMounted,
  onBeforeUpdate,
  onUpdated,
  onBeforeUnmount,
  onUnmounted,
} from 'vue'

/* 接口 */
import apiHttpFn from '@/api/index'

interface PrizesLevelsListData {
  id: number | null
  prizeName: string
  levelName: string
  phValue: number | null
  dataIndex: number | null
  state: number | null
}

// 定义数据

const tokenData = localStorage.getItem('GIS_USER_LOGIN_IDSTR') || ''

// 奖品等级数据
const prizesLevelsListData = ref<PrizesLevelsListData[]>()

const getLevesData = () => {
  apiHttpFn.getCardListHttp(tokenData).then((res) => {
    prizesLevelsListData.value = res.data?.data || []
    console.log(res)
  })
}

defineExpose({
  getLevesData,
})

onBeforeMount(() => {
  getLevesData()
})
onMounted(() => {
  console.log('onMounted')
})
onUnmounted(() => {
  console.log('onUnmounted')
})
</script>
<style lang='scss' scoped>
</style>
